using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Input;

namespace Empanada
{
    public class Model : INotifyPropertyChanged
    {
        private ObservableCollection<EmpanadaPendingChange> _pendingChanges = new ObservableCollection<EmpanadaPendingChange>();
        private string _workspaceDisplayName;
        private Uri _collectionUri;
        private string _selectedServerPath;
        private bool _checkOutFilesOnEdit;
        private string _checkInComment = string.Empty;

        public event PropertyChangedEventHandler PropertyChanged;

        void OnPropertyChanged(string propertyName)
        {
            var propertyChanged = PropertyChanged;
            if (propertyChanged != null)
            {
                propertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        public ObservableCollection<EmpanadaPendingChange> PendingChanges
        {
            get { return _pendingChanges; }
            set
            {
                _pendingChanges = value;
                OnPropertyChanged("PendingChanges");
            }
        }

        public string WorkspaceDisplayName
        {
            get { return _workspaceDisplayName; }
            set 
            { 
                _workspaceDisplayName = value;
                OnPropertyChanged("WorkspaceDisplayName");
            }
        }

        public bool CheckOutFilesOnEdit
        {
            get { return _checkOutFilesOnEdit; }
            set
            {
                _checkOutFilesOnEdit = value;
                OnPropertyChanged("CheckOutFilesOnEdit");
            }
        }

        public Uri CollectionUri
        {
            get { return _collectionUri; }
            set 
            {
                _collectionUri = value;
                OnPropertyChanged("CollectionUri");
            }
        }

        public string SelectedServerPath
        {
            get { return _selectedServerPath; }
            set
            {
                _selectedServerPath = value;
                OnPropertyChanged("SelectedServerPath");
            }
        }

        public string CheckInComment
        {
            get { return _checkInComment; }
            set
            {
                _checkInComment = value;
                OnPropertyChanged("CheckInComment");
            }
        }

        public ICommand AddSelectedFileCommand { get; set; }

        public ICommand CheckOutSelectedFileCommand { get; set; }

        public ICommand CheckInSelectedFileCommand { get; set; }

        public ICommand UndoSelectedFileCommand { get; set; }

        public ICommand GetLatestSelectedFileCommand { get; set; }
    }
}

